<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script src="./index.js"></script>

    <script>
       save("郭佳俊","大傻子")

    //    定义一个类
    function Singleton(name){
        this.name=name;
        this.instance=null;
    }

    // 原型扩展类的一个方法
    Singleton.prototype.getName=function(){
        console.log(this.name);
    }

    // 获取类的实例
    Singleton.getInstance=function(name){
        if(!this.instance){
            this.instance=new Singleton(name)
        }
        return this.instance
    }

    // 获取对象
    let a=Singleton.getInstance("a");
    // 获取对象2
    let b=Singleton.getInstance("b");
    // 进行比较   true
    console.log(a===b); 
    </script>
</body>
</html>